<template>
  <div id="app">
    <router-view/>
  </div>
</template>
<script>
import axios from "axios";

import {mapMutations,mapState} from "vuex";
export default {
  methods:{...mapMutations(["setIsLogin"])},
  computed:{...mapState(['userId','user'])},
  mounted() {
    axios.get("/user/state/" + this.userId).then(r => {
      console.log(r)
      if (r.data.state === 20000) {

        this.setIsLogin(true)
        //获取头像、昵称
        axios.get("/user/menuSource/" + this.userId).then(r => {
          this.user.nick = r.data.data.nick
          this.user.avatar = r.data.data.avatar
          console.log(this.user.avatar)
        }).catch(e => console.log(e))
      } else {
        this.setIsLogin(false)
      }
    }).catch(e => console.log(e))
  }
}
</script>
<style>
*{margin: 0;padding: 0}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  width: 1200px;
  margin: 0 auto;
}
</style>
